<template>
	<view class="height356 ibg1B89F2-0468CA ">
		<view class="con  pb140" :style="{paddingTop:shh+'px'}">
			<view class="colorfff size35 pt20" >企业政策AI</view>
			<swiper class="swiper height340 mt50">
				<swiper-item v-for="(item,index) in banner" :key="index">
					<view @click="navto('news_detail?id='+item.link)" class="">
						<image  class="image height340 ra15" :src="item.img"></image>
					</view>
				</swiper-item>
			</swiper>
			<view class="ra15 bgffff mt30 pg25">
				<view class="flex-ju-b">
					<view class="flex-ju-a flex1">
						<view @click="taplist(index)" :class="{color0E74CF:tindex==index}" v-for="(item,index) in ['正在申报','正在公示','新发文件']" :key="index">{{item}}</view>
					</view>
					<view @click="navto('news_list')" class="ml50">
						<uni-icons type="right" size="18" color="#A9A9A9"></uni-icons>
					</view>
				</view>
				<view v-if="isdata1" class="flex-ju-c color999 mt10vh">
					暂无数据
				</view>
				<template v-if="tindex==0" v-for="(item,index) in list" :key="index">
					<template v-if="index<4">
						<view  @click="navto('/pages/user/recoer_detail?id='+item.id)" class="flex-ju-b  mt30  " >
							<view  class=" ">
								<view class="flex-a-i">
									<!-- <view class="bg0E74CF ra10 wh10-40"></view> -->
									<view class="size24 colorB8B8B8 ">{{item.create_time}}</view>
								</view>
								<view class="size24 mt15">
									地区：{{item.company.province}} {{item.company.area}} {{item.company.city}}
								</view>
								<view class="size24 mt15">
									申报企业：{{item.company.name}}
								</view>
							</view>
							<view class="size26">
								{{item.status_name}}
							</view>
						</view>
					</template>
				</template>
				
				
				<view v-else v-for="(item,index) in document" :key="item.id" @click="navto('./news_detail?id='+item.id)" class="flex-a-i mt30">
						<view>
							<image :src="item.image_input[0]" class="wh220-140 ra10"></image>
						</view>
						<view  class="ml20  flex1 ">
							<view class="one size30 " style="max-width: 350rpx;">{{item.title}}</view>
							<view class="one size25 colorB8B8B8 mt5" style="max-width: 350rpx;">
								{{item.synopsis}}
							</view>
							<view class="size20 colorB8B8B8 mt5">{{item.add_time}}</view>
						</view>
				</view>
				
			</view>
			<view class="ra15 bgffff mt30 pg25">
				<view @click="navto('video_list')" class="flex-ju-b">
					<view class="flex-ju-a">
						<image mode="widthFix" class="width30" src="/static/shiping.png"></image>
						<view class="size25 ml5">视频专区</view>
					</view>
					<uni-icons type="right" size="18" color="#A9A9A9"></uni-icons>
				</view>
				<view v-if="isdata2" class="flex-ju-c color999 mt10vh">
					暂无数据
				</view>
				<view class="flex-ju-b flex-wrap ">
					
					<view v-for="(item,index) in videolist" :key="item.id" @click="navto('video_detail?id='+item.id)" class="flex flex-col posire mt30" style="width: 48%;">
							<image :src="item.image_input[0]" class="height200 width1000 ra10"></image>
							<view class="size26 mt5 mb5 one">{{item.title}}</view>
							<view class="size20 colorb8b8b8">{{item.add_time}}</view>
							<view class="flex-ju-c posiab height200 width1000">
								<image src="/static/bofang.png" class="width70 image" mode="widthFix"></image>
							</view>
					</view>
				</view>
			</view>
			<view class="ra15 bgffff mt30 pg25">
				<view @click="navto('advertisement_list')" class="flex-ju-b">
					<view class="flex-ju-a">
						<image mode="widthFix" class="width30" src="/static/shiping.png"></image>
						<view class="size25 ml5">广告</view>
					</view>
					<uni-icons type="right" size="18" color="#A9A9A9"></uni-icons>
				</view>
				<view v-if="isdata3" class="flex-ju-c color999 mt10vh">
					暂无数据
				</view>
					<view v-for="(item,index) in Advert" :key="item.id" @click="navto('./advertisement_detail?id='+item.id)" class="flex-a-i mt30">
					<view>
						<image :src="item.image_input[0]" class="wh220-140 ra10"></image>
					</view>
										
					<view class="ml20">
						<view class="one size30 mt15">{{item.title}}</view>
						<view class="one size25 colorB8B8B8 mt5">
							{{item.synopsis}}
						</view>
						<view class="size20 colorB8B8B8 mt5">{{item.add_time}}</view>
					</view>
				</view> 
			</view>
		</view>
	</view>
	
</template>

<script>
	export default {
		data() {
			return {
				category_list:[],
				isdata1:false,
				isdata2:false,
				isdata3:false,
				banner:[],
				tindex:0,
				videolist:[],
				Advert:[],
				document:[],
				list:[]
			}
		}, 
		onShow() {
			this.http('company/apply_list',{status:0,limit:4}).then(res=>{
				this.list=res.data.list
				if(this.list.length){
					this.isdata1 = false
				}else{
					this.isdata1 = true
				}
			}).catch(res=>{
				if(this.list.length){
					this.isdata1 = false
				}else{
					this.isdata1 = true
				}
			})
		},
		onLoad() {
			if (process.env.UNI_PLATFORM != "h5") {
				uni.showShareMenu()
			}
			// 4新发文件
			// 3企业广告
			// 2视频专区
			// 1正在公示
			
			
			this.http('/groom/list/1').then(res=>{
				this.banner = res.data.banner
			})
			this.http('/article/list/2',{limit:4}).then(res=>{
				this.videolist=res.data
				if(this.videolist.length){
					this.isdata2 = false
				}else{
					this.isdata2 = true
				}
			})
			this.http('/article/list/3',{limit:4}).then(res=>{
				this.Advert=res.data
				if(this.Advert.length){
					this.isdata3 = false
				}else{
					this.isdata3 = true
				}
			})
			
			
			
			this.http('/article/category/list').then(res=>{
				this.category_list=res.data
				// res.data.map(item=>{
				// 	if(item.title.indexOf('视频') != -1 ){
				// 		this.http('/article/list/'+item.id).then(res=>{
				// 			this.videolist=res.data
				// 		})
				// 	}else if(item.title.indexOf('广告') != -1){
				// 		this.http('/article/list/'+item.id).then(res=>{
				// 			this.Advert=res.data
				// 		})
				// 	}else if(item.title.indexOf('公示') != -1){
				// 		this.http('/article/list/'+item.id).then(res=>{
				// 			this.Advert=res.data
				// 		})
				// 	}
				// })
			})
			
			
		},
		methods: {
			
			taplist(index){
				this.tindex =index
				if(index==2){
					this.http('/article/list/4',{limit:4}).then(res=>{
						this.document=res.data
						if(this.document.length){
							this.isdata1 = false
						}else{
							this.isdata1 = true
						}
					})
				}else if(index==1){
					this.http('/article/list/1',{limit:4}).then(res=>{
						this.document=res.data
						if(this.document.length){
							this.isdata1 = false
						}else{
							this.isdata1 = true
						}
					})
				}else{
					this.http('company/apply_list',{status:0,limit:4}).then(res=>{
						this.list=res.data.list
						if(this.list.length){
							this.isdata1 = false
						}else{
							this.isdata1 = true
						}
					}).catch(res=>{
						if(this.list.length){
							this.isdata1 = false
						}else{
							this.isdata1 = true
						}
					})
				}
			}
		}
	}
</script>

<style>
	
	 .color0E74CF{
		 color: #0E74CF;
		 font-weight: bold;
	 }
	 .fflexb{
		 flex:0 0 48%;
	 }
</style>
